home *** CD-ROM | disk | FTP | other *** search
/ OpenGL Superbible (2nd Edition) / OpenGL SuperBible e2.iso / tools / GLUT-3.7 / PROGS / DEMOS / GEOFACE / MEMORY.H < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-12  |  952 b   |  30 lines

  1. /* ==========================================================================
  2.                                 MEMORY_H                              
  3. =============================================================================
  4.  
  5.       AUTHOR: Keith Waters
  6.       DATE  : Tue Jan  7 10:16:52 EST 1992
  7.  
  8.       SYNOPSIS
  9.          Memory macros.
  10.  
  11.       DESCRIPTION
  12.          Simple memory macros for allocation.
  13.  
  14. ============================================================================ */
  15.  
  16.  
  17. #ifndef    MEMORY_H
  18. #define    MEMORY_H
  19.  
  20.  
  21. #define    _new(t)            ((t*)malloc(sizeof(t)))
  22. #define    _new_array(t, n)    ((t*)malloc(sizeof(t) * (n)))
  23. #define    _resize_array(a, t, n)    ((t*)realloc((a), sizeof(t) * (n)))
  24. #define _size_array(a,t,n0,n1)  a = (n0 == 0 ? _new_array(t,n1) : \
  25.                                                _resize_array(a,t,n1))
  26. #define    _delete(object)        ((void)(((object)!=NULL) ? \
  27.                     free((char*)(object)),(object)=NULL : 0))
  28. #endif    /* _MEMORY_H */
  29.  
  30.